home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Installer SDK Cornucopia 1.0.2 / Script Examples / Install App Fat⁄PPC⁄68K / NotPPC / NotPPC.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-17  |  2.0 KB  |  74 lines  |  [TEXT/MPS ]

  1. /*
  2.  
  3.     NotPPC.c
  4.  
  5.         Source code for NotPPC application to provide a warning
  6.         when PowerMac Native Mode application is launched on a
  7.         68K machine.
  8.         
  9.         Note: This module has been observed to put up only a partial
  10.         error message when launched under System 7.5. It does however
  11.         look fine under System 7.1.
  12.  
  13. */
  14.  
  15. #include <dialogs.h>
  16. #include <QuickDraw.h>
  17. #include <Dialogs.h>
  18. #include <Windows.h>
  19. #include <Resources.h>
  20. #include <Memory.h>
  21. #include "NotPPC.h"
  22.  
  23. // When using 3.3.1 or newer MPW these are no longer in Dialogs.h, so we put them here.  If you're using an
  24. // older MPW then comment out the following lines.
  25. pascal void CouldAlert(short alertID)
  26.  = 0xA989; 
  27. pascal void FreeAlert(short alertID)
  28.  = 0xA98A; 
  29.  
  30. /* The qd global has been removed from the libraries */
  31. QDGlobals qd;
  32.  
  33.  
  34. void main ()
  35. {
  36.     short        itemHit;
  37.     AlertTHndl    theAlertTemplate;
  38.     Handle        theDITLHandle;
  39.     Handle        theMessageHandle;
  40.     Boolean        canAlert;
  41.  
  42.     InitGraf ((Ptr) &qd.thePort);
  43.     InitWindows ();
  44.     InitDialogs (NULL);
  45.     InitCursor();                                                            /* set to arrow and make visible */
  46.     
  47.     /* pre-flight everything first */
  48.     theAlertTemplate = (AlertTHndl)GetResource ('ALRT', RESOURCE_ID);        /* is the ALRT resource around? */
  49.     theDITLHandle = GetResource ('DITL', (*theAlertTemplate)->itemsID);        /* how about the DITL? */
  50.     theMessageHandle = GetResource ('STR ', RESOURCE_ID);                    /* check the STR resource, too */
  51.  
  52.     CouldAlert (RESOURCE_ID);                                                /* is there enough memory to handle the alert? */
  53.     canAlert = (ResError() == noErr) && (MemError() == noErr);
  54.     FreeAlert (RESOURCE_ID);                                                /* free the memory */
  55.  
  56.     if ((theAlertTemplate) || (theDITLHandle) || (theMessageHandle) || (canAlert))
  57.     {
  58.         /* Success at last... */
  59.         HLock( theMessageHandle );
  60.         ParamText ((unsigned char const *)(theMessageHandle),
  61.                     (unsigned char const *)"",
  62.                     (unsigned char const *)"",
  63.                     (unsigned char const *)"");    /* use the loaded STR resource to replace ^0 in alert's DITL */
  64.         itemHit = Alert (RESOURCE_ID, nil);                                    /* run the alert */
  65.     }
  66.     else
  67.     {
  68.         /* give some indication we're hosed... */
  69.         SysBeep(2); 
  70.     }
  71. }
  72.  
  73.  
  74.